package com.yitongmao.core.network.api;

import java.util.HashMap;
import java.util.Map;

import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PartMap;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import retrofit2.http.Url;


/**
 * 通用api接口类
 */
public interface BaseApiInterface<T> {
    /**
     * 直接使用Url get请求
     */
    @GET
    Call<String> simpleGetMethod(@Url String dynamicUrl);

    @GET
//    @Headers({"Accept-Encoding: gzip", "Content-Type: application/json;charset=UTF-8"})
    @Headers({"Content-Type: application/json;charset=UTF-8"})
    Call<String> simpleGetMethodHasHead(@Url String dynamicUrl);

    /**
     * 直接使用Url get请求
     */
    @GET
    Call<ResponseBody> downloadGetMethod(@Url String dynamicUrl);

    /**
     * 直接使用Url Post请求
     */
    @FormUrlEncoded
    @POST
    @Headers({"Content-Type: application/json;charset=UTF-8"})
    Call<String> postMethod(@Url String dynamicUrl, @FieldMap HashMap<String, String> params);

    /**
     * 直接使用Url Post请求
     */
    @FormUrlEncoded
    @POST
    Call<String> PostMethodNoHeader(@Url String dynamicUrl, @FieldMap HashMap<String, String> params);

    /**
     * 直接使用Url Post请求
     */
    @FormUrlEncoded
    @POST
    @Headers({"Content-Type: application/x-www-form-urlencoded"})
    Call<String> PostMethodMemBer(@Url String dynamicUrl, @FieldMap Map<String, String> params);


    /**
     * get请求
     *
     * @param url
     */
    @GET("/{url}")
    Call<String> customGetMethod(@Path(value = "url", encoded = true) String url);


    /**
     * post请求
     *
     * @param url
     * @param params
     */
    @FormUrlEncoded
    @Headers({"Content-Type: application/json;charset=UTF-8"})
    @POST
    Call<String> customPostMethod(@Url String url,
                                  @FieldMap HashMap<String, String> params);

    /**
     * post请求
     *
     * @param url
     * @param params
     */
    @FormUrlEncoded
    @POST
    Call<String> customPostMethodNoHead(@Url String url,
                                        @FieldMap HashMap<String, String> params);


    /**
     * 上传单文件和多文件接口
     *
     * @param dynamicUrl
     * @param files
     */
    @Multipart
    @POST
    Call<String> customMultiFileUpload(
            @Url String dynamicUrl,
            @PartMap Map<String, RequestBody> files
    );
    //复制了
    @Multipart
    @POST
    Call<String> customMultiFileUpload(
            @Url String dynamicUrl,
        @PartMap Map<String, RequestBody> files,@Query("userId") String userId
    );

    /**
     * 传递复杂参数，直接传递对象，body
     *
     * @param model
     */
    @POST("/{url}")
    <T> void customPostBody(@Body BaseRequestModel model);


    /**
     * 下载文件
     *
     * @return
     */
    @Streaming
    @GET("/{url}")
    Call<ResponseBody> downloadFile(@Path(value = "url", encoded = true) String url);


    //业务bean
//    @POST
//    Call<String> customPostMethodBean(@Url String url,
//                                      @Body BaoliaoPostBean bean);


}
